package main

import "fmt"

func main() {
	fmt.Println(findPoisonedDuration([]int{1, 3}, 2))
}

func findPoisonedDuration(timeSeries []int, duration int) (ans int) {
	last := 0
	for _, ts := range timeSeries {
		if ts >= last {
			ans += duration
		} else {
			ans += ts - last + duration
		}
		last = ts + duration
	}
	return
}
